<template>
	<footer class="footer">
		<span class="todo-count" >剩余<strong>{{leftCount}}</strong></span>
		<ul class="filters">
			<li>
				<a :class="{selected:selectType==='all'}" href="javascript:;" @click="changeType('all')">全部</a>
			</li>
			<li>
				<a href="javascript:;" :class="{selected:selectType==='active'}" @click="changeType('active')">未完成</a>
			</li>
			<li>
				<a href="javascript:;" :class="{selected:selectType==='over'}" @click="changeType('over')">已完成</a>
			</li>
		</ul>
		<button class="clear-completed" @click="del" v-show="showClear">清除已完成</button>
	</footer>
</template>

<script>
	export default {
		props:{
			arr:{
				type:Array,
				required:true
			}
		},
		computed:{
			//剩余数量
			leftCount(){
				return this.arr.filter(item=>!item.isDone).length
			},
			showClear(){
				return this.arr.some(item=>item.isDone)
			}
		},
		methods: {
			del(){
				this.$emit('clearDone')
			},
			changeType(type){
				this.selectType=type
				this.$emit('changeType',type)
			}
		},
		data(){
			return {
				selectType:'all'
			}
		}
	}
</script>
